from django.conf.urls import url
from rest_framework import routers
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.views import admin
from meiduo_admin.views import brand
from meiduo_admin.views import channel
from meiduo_admin.views import group
from meiduo_admin.views import image
from meiduo_admin.views import orders
from meiduo_admin.views import permission
from meiduo_admin.views import skus
from meiduo_admin.views import specificationoption
from meiduo_admin.views import specs
from meiduo_admin.views import spus
from meiduo_admin .views import statistical
from meiduo_admin.views import users

urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),

    # 1用户总数统计
    url(r'statistical/total_count/$',statistical.UserTotalCountView.as_view()),
    # 2日增用户统计
    url(r'statistical/day_increment/$',statistical.UserDayCountView.as_view()),
    # 3日活用户统计
    url(r'statistical/day_active/$',statistical.UserActiveCountView.as_view()),
    # 4下单用户统计
    url(r'statistical/day_orders/$',statistical.UserOrderCountView.as_view()),
    # 5月新增用户统计
    url(r'statistical/month_increment/$',statistical.UserMonthCountView.as_view()),
    # 6商品访问量统计
    url(r'^statistical/goods_day_views/$',statistical.GoodsDayView.as_view()),
    #------------用户的获取增加----------
    url(r'^users/$',users.UserView.as_view()),
    # ------------------商品规格表管理------------------
    url(r'^goods/simple/$', specs.SpecView.as_view({'get': 'simple'})),
    # ------------------商品id管理------------------
    url(r'^skus/simple/$',image.ImageView.as_view({'get':'simple'})),
    # ------------------商品分类管理查询------------------
    url(r'^skus/categories/$',skus.SKUGoodsView.as_view({'get':'categories'})),
    # ------------------spu商品规格信息------------------
    url(r'^goods/(?P<pk>\d+)/specs/$',skus.SKUGoodsView.as_view({'get':'specs'})),
    #---------------------获取权限表数据-----------------------
    url(r'permission/simple/$',group.UserGroupView.as_view({'get':'simple'})),
    #---------------------获取分组表数据-----------------------
    url(r'permission/groups/simple/$',admin.AdminView.as_view({'get':'simple'})),
    #---------------------获取品牌信息表数据-----------------------
    url(r'goods/brands/simple/$',spus.SPUGoodView.as_view({'get':'brand'})),
    # ---------------------获取一级表数据-----------------------
    url(r'goods/channel/categories/$', spus.SPUGoodView.as_view({'get': 'channel'})),
    # ---------------------获取二级三级表数据-----------------------
    url(r'goods/channel/categories/(?P<pk>\d+)/$', spus.SPUGoodView.as_view({'get': 'channels'})),
    # ---------------------上传图片-----------------------
    url(r'goods/images/$', spus.SPUGoodView.as_view({'post': 'image'})),
    # ---------------------获取权限类型列表数据-----------------------
    url(r'permission/content_types/$', permission.PermissionView.as_view({'get': 'content_types'})),
    # ---------------------获取规格-----------------------
    url(r'goods/specs/simple/$', specificationoption.SpecificationoptionView.as_view({'get': 'simple'})),
    # ---------------------获取组表数据-----------------------
    url(r'goods/channel_types/$', channel.GoodsChannelView.as_view({'get': 'groups'})),
    # ---------------------获取一级表数据-----------------------
    url(r'goods/categories/$', channel.GoodsChannelView.as_view({'get': 'categorys'})),


]



# ------------------商品规格表管理------------------
router = routers.SimpleRouter()
router.register(r'goods/specs',specs.SpecView,base_name='spec')
print(router.urls)
urlpatterns += router.urls

# ------------------图片管理------------------
router = DefaultRouter()
router.register('skus/images',image.ImageView,base_name='image')
print('***',router.urls)
urlpatterns += router.urls
# ------------------SKU表管理------------------
router = routers.SimpleRouter()
router.register(r'skus',skus.SKUGoodsView,base_name='skus')
urlpatterns += router.urls

# ------------------订单表管理------------------
router = routers.SimpleRouter()
router.register(r'orders',orders.OrdersView,base_name='order')
urlpatterns += router.urls
# ------------------用户组管理------------------
router = routers.SimpleRouter()
router.register(r'permission/groups',group.UserGroupView,base_name='group')
urlpatterns += router.urls
# ------------------管理员管理------------------
router=routers.SimpleRouter()
router.register(r'permission/admins',admin.AdminView,base_name='admin')
urlpatterns += router.urls
# --------------------品牌----------
router = routers.DefaultRouter()
router.register(r'goods/brands',brand.BrandView,base_name='brands')
urlpatterns += router.urls

# ------------------频道表列表数据------------------
router = routers.SimpleRouter()
router.register(r'goods/channels',channel.GoodsChannelView,base_name='channel')
urlpatterns += router.urls

# ------------------SPU表管理------------------
router = routers.SimpleRouter()
router.register(r'goods',spus.SPUGoodView,base_name='spus')
urlpatterns += router.urls
# --------------------获取权限类型列表数据----------
router = routers.SimpleRouter()
router.register(r'permission/perms',permission.PermissionView,base_name='permission')
urlpatterns += router.urls
# ------------------规格选项表列表数据------------------
router = routers.SimpleRouter()
router.register(r'specs/options',specificationoption.SpecificationoptionView,base_name='specificationoption')
urlpatterns += router.urls
